package webmarket.model;

import java.util.SortedSet;
import java.util.TreeSet;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.eclipse.persistence.oxm.annotations.XmlInverseReference;

import webmarket.common.XmlBase;

/**
 * The persistent class for the shopcategory database table.
 * 
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(propOrder = { "id", "name", "description", "icon", "children" })
public class Shopcategory extends XmlBase implements Comparable<Shopcategory> {
	private static final long serialVersionUID = -4701014017680773520L;
	@XmlElement
	private int id;

	@XmlElement
	private String description;

	@XmlElement
	private String name;

	@XmlElement(required = false)
	private String icon;

	@XmlInverseReference(mappedBy = "children")
	private Shopcategory parent;

	@XmlElement(name = "shopcategory")
	@XmlElementWrapper(name = "children")
	private SortedSet<Shopcategory> children = new TreeSet<Shopcategory>();

	public Shopcategory() {
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the parent
	 */
	public Shopcategory getParent() {
		return parent;
	}

	/**
	 * @param parent
	 *            the parent to set
	 */
	public void setParent(Shopcategory parent) {
		this.parent = parent;
	}

	/**
	 * @return the children
	 */
	public SortedSet<Shopcategory> getChildren() {
		return children;
	}

	/**
	 * @param children
	 *            the children to set
	 */
	public void setChildren(SortedSet<Shopcategory> children) {
		this.children = children;
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	@Override
	public int compareTo(Shopcategory o) {
		return getName().compareTo(o.getName());
	}

	/**
	 * @return the icon
	 */
	public String getIcon() {
		return icon;
	}

	/**
	 * @param icon
	 *            the icon to set
	 */
	public void setIcon(String icon) {
		this.icon = icon;
	}

}